package com.david.rabbitmq.taskqueue;

import com.david.rabbitqm.util.ChannelUtlis;
import com.rabbitmq.client.Channel;

import java.io.IOException;

/**
 * @author David
 * @version V1.0
 * @Package com.david.rabbitmq.taskqueue
 * @date 2021/7/17 9:14
 */
public class TaskQueueProducer {

    private static final String QUEUE_NAME = "task_queue";

    public static void main(String[] args) throws IOException, InterruptedException {
        Channel channel = ChannelUtlis.getChannel();
        channel.queueDeclare(QUEUE_NAME,false,false,false,null);
        for (int i = 0; i < 100; i++) {
            // 将消息路由到taskQueue队列
            channel.basicPublish("", QUEUE_NAME, null, (i+"").getBytes());
            System.out.println(" [x] Sent '" + i + "'");
            Thread.sleep(1000L);
        }
    }
}
